Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
convert array into array with key and parenthesis in the form [{fruit:"apple"},{fruit:"banana"},{fruit:"mango}]

could you please tell me how to convert an array which is

["apple","banana", "mango"]

to

[{fruit:"apple"},{fruit:"banana"},{fruit:"mango}]

with the parenthesis

something similar to this but with parenthesis JavaScript Add key to each value in array

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're still looking for the .map() function, just like that other question. The only difference is that you want to return an object from the callback, not just a string.

For example:

let input = ["apple","banana", "mango"];
console.log(input.map(x => ({fruit: x})));

As an aside, {} are not parentheses, they are curly braces.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!